class Animal{
    name: string;
    constructor( name: string ) {
        this.name = name
    }
    eat() {//在父类只是声明一个方法，该方法的具体功能需要继承它的子类去实现
        console.log('吃的方法');
        
    }
}

class Dog extends Animal{
    constructor( name: string ) {
        super(name)
    }
    eat() {
        return this.name + '吃肉'   
    }
}

class Cat extends Animal{
    constructor( name: string ) {
        super(name)
    }
    eat() {
        return this.name + '吃猫粮'
    }
}